package com.itheima.d5_genericity;

public class TestMethod {
    public static void main(String[] args) {
        String[] names = {"Java", "Mybatis", "SQL"};
        Integer[] ages = {10, 20, 30};
        printArray(names);
        printArray(ages);
    }
    public static <T> T[] p(T[] arr){
        return arr;
    }

    public static <T> void printArray(T[] arr) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        if (arr != null) {
            for (int i = 0; i < arr.length; i++) {
                if(i == arr.length -1){
                    sb.append(arr[i]);
                }else{
                    sb.append(arr[i]).append(",");
                }
            }
            sb.append("]");
            System.out.println(sb.toString());
        } else {
            System.out.println(arr);
        }
    }
}
